#parse argument

architecture=$1
matrix_decompressed_file=$2
matrix_comp_file=$3
output_dir=$4
lorem_ipsum_file=$5

permutation_str=""

# generate point

str="
xrnlib-cli \
    --encoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture \
    --make-point -point $output_dir/point0.xf 
"
echo ""; echo $str; echo ""
eval $str

# generate key

str="
xrnlib-cli \
    --encoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture $permutation_str \
    --make-monomial-key -monomial-key $output_dir/monomial_key_file.xf 
"
echo ""; echo $str; echo ""
eval $str

# generate key

str="
xrnlib-cli \
    --encoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture $permutation_str \
    --make-monomial-key -monomial-key $output_dir/monomial_key_file2.xf 
"
echo ""; echo $str; echo ""
eval $str

# generate next point

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --encoding-conf -compiled-param -no-password \
    --arithmetic-conf -point $output_dir/point0.xf -monomial-key $output_dir/monomial_key_file.xf \
    --sequence-conf -xmatrix $matrix_decompressed_file \
    --permutation-conf -arch $architecture \
    --make-confidential-pseudo-random-number -next-point $output_dir/point1_0.xf "

echo ""; echo $str; echo ""
eval $str

# regenerate next point

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --encoding-conf -compiled-param -no-password \
    --arithmetic-conf -point $output_dir/point0.xf -monomial-key $output_dir/monomial_key_file.xf \
    --sequence-conf -xmatrix $matrix_decompressed_file \
    --permutation-conf -arch $architecture \
    --make-confidential-pseudo-random-number -next-point $output_dir/point1_1.xf "

echo ""; echo $str; echo ""
eval $str

# regenerate next next point

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --encoding-conf -compiled-param -no-password \
    --arithmetic-conf -point $output_dir/point1_0.xf -monomial-key $output_dir/monomial_key_file.xf \
    --sequence-conf -xmatrix $matrix_decompressed_file \
    --permutation-conf -arch $architecture \
    --make-confidential-pseudo-random-number -next-point $output_dir/point2.xf "

echo ""; echo $str; echo ""
eval $str

# generate other point

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --encoding-conf -compiled-param -no-password \
    --arithmetic-conf -point $output_dir/point0.xf -monomial-key $output_dir/monomial_key_file2.xf \
    --sequence-conf -xmatrix $matrix_decompressed_file \
    --permutation-conf -arch $architecture \
    --make-confidential-pseudo-random-number -next-point $output_dir/point3.xf "

echo ""; echo $str; echo ""
eval $str

# convert and compare the two computed points

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture \
    --logging-conf -lib-info-log $output_dir/point1_0.json \
    --print-header -xrn-file $output_dir/point1_0.xf
"
echo ""; echo $str; echo ""
eval $str

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture \
    --logging-conf -lib-info-log $output_dir/point1_1.json \
    --print-header -xrn-file $output_dir/point1_1.xf
"
echo ""; echo $str; echo ""
eval $str

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture \
    --logging-conf -lib-info-log $output_dir/point2.json \
    --print-header -xrn-file $output_dir/point2.xf
"
echo ""; echo $str; echo ""
eval $str

str="
xrnlib-cli \
    --decoding-conf -compiled-param -no-password \
    --permutation-conf -arch $architecture \
    --logging-conf -lib-info-log $output_dir/point3.json \
    --print-header -xrn-file $output_dir/point3.xf
"
echo ""; echo $str; echo ""
eval $str

str=" 
cmp --silent $output_dir/point1_1.json $output_dir/point1_0.json || echo 'FAIL'
"
echo ""; echo $str; echo ""
eval $str

str=" 
cmp --silent $output_dir/point1_0.json $output_dir/point2.json && echo 'FAIL'
"
echo ""; echo $str; echo ""
eval $str

str=" 
cmp --silent $output_dir/point1_0.json $output_dir/point3.json && echo 'FAIL'
"
echo ""; echo $str; echo ""
eval $str

